/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
/*
* A function that can be attached to a form's
* onkeydown event to enable form submission
* when the enter key is pressed
*/
function submitOnEnter(evt){
    if(!evt) evt = event;
    if( evt.keyCode==13 ){
        var eventSrc = null;
        if(!evt.target) eventSrc = evt.srcElement;
        else eventSrc = evt.target;
        var formElements = eventSrc.form.elements;
        for( var i=0;i<=formElements.length;i+=1){
            var formElement = formElements[i];
            if(formElement.type != null && formElement.type.toLowerCase() == 'submit'){
                formElement.click();
                break;
            }
        }
    }
}
/*
 * Mayusculas con evento de key press no jquery
 *
 */

function mayusculas(e){
    tecla = (document.all) ? e.keyCode : e.which;
    if(tecla == 9 || tecla == 0) return true;
    if(tecla == 8) return true;
    obj=(!e.target?e.srcElement:e.target)
    var pst = getCaretPos(obj);
    var string_start = obj.value.substring(0,pst);
    var string_end = obj.value.substring(pst ,obj.value.length);
    obj.value = string_start+ String.fromCharCode(tecla).toUpperCase()+ string_end;
    setCaretPosition(obj,pst+1);
    e.stopPropagation();
    return false;
}
function getCaretPos(el) {
    if (typeof el.selectionStart != "undefined")
        return el.selectionStart;
    else if (document.selection)
        return Math.abs(document.selection.createRange().moveStart("character", -1000000));
}
function setCaretPosition (oField, iCaretPos) {
    // IE Support
    if (document.selection) {
        // Set focus on the element
        oField.focus ();
        // Create empty selection range
        var oSel = document.selection.createRange ();
        // Move selection start and end to 0 position
        oSel.moveStart ('character', -oField.value.length);
        // Move selection start and end to desired position
        oSel.moveStart ('character', iCaretPos);
        oSel.moveEnd ('character', iCaretPos);
        oSel.select ();
    }
    // Firefox support
    else if (oField.selectionStart || oField.selectionStart == '0') {
        oField.selectionStart = iCaretPos;
        oField.selectionEnd = iCaretPos;
        oField.focus ();
    }
}
function setSelectItem(idField,SelectedIndex){
    alert("Holas");
    idField.selectedIndex=SelectedIndex;
}